<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!--右侧主内容-->
<div class="yui3-u-5-6">
    <div class="body userAddress">
        <div class="address-title">
            <span class="title">地址管理</span>
            <a data-toggle="modal" data-target=".edit" data-keyboard="false"   class="sui-btn  btn-info add-new">添加/修改地址</a>
            <span class="clearfix"></span>
        </div>
        <div class="address-detail">
            <table class="sui-table table-bordered">
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>地址</th>
                    <th>联系电话</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>${address.realName}</td>
                    <td>${address.address}</td>
                    <td>${address.phone}</td>
                    <td>默认地址</td>
                </tr>
                </tbody>
            </table>
        </div>
        <!--新增地址弹出层-->
        <div  tabindex="-1" role="dialog" data-hasfoot="false" class="sui-modal hide fade edit" style="width:580px;">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" data-dismiss="modal" aria-hidden="true" class="sui-close">×</button>
                        <h4 id="myModalLabel" class="modal-title">添加/修改地址</h4>
                    </div>
                    <div class="modal-body">
                        <form class="sui-form form-horizontal" id="form" autocomplete="off">
                            <%--隐藏域提交用户名--%>
                            <input type="hidden" value=${Username} name="username">
                            <div class="control-group">
                                <label class="control-label">收货人：</label>
                                <div class="controls">
                                    <input type="text" class="input-medium" name="realName" value="${address.realName}">
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label">详细地址：</label>
                                <div class="controls">
                                    <input type="text" class="input-large" name="address" value="${address.address}" style="width: 360px">
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label">联系电话：</label>
                                <div class="controls">
                                    <input type="text" class="input-medium" name="phone" value="${address.phone}">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button id="save" type="button" data-ok="modal" class="sui-btn btn-primary btn-large">确定</button>
                        <button type="button" data-dismiss="modal" class="sui-btn btn-default btn-large">取消</button>
                    </div>
                </div>
            </div>
        </div>
        <script>
            $(function () {
                $("#save").click(function () {
                    $.ajax({
                        url:'${pageContext.request.contextPath}/goods/saveAddress',
                        data:$("#form").serialize(),
                        type:'GET',
                        contentType:'application/json;charset=utf-8',
                        dataType:'json',
                        success:function (res) {
                            if(res.type === 'success'){
                                location.reload();
                            }else{

                            }
                        }
                    })
                })
            })
        </script>
    </div>
</div>
